"use strict";function read_hex_file(e){e=e.split("\n"),""==e[e.length-1]&&e.pop();for(var s=!0,t={data:[],end_of_file:!1,bytes_total:0,start_linear_address:0},a=0,r=0,n=0;n<e.length&&s;n++){var o=parseInt(e[n].substr(1,2),16),d=parseInt(e[n].substr(3,4),16),i=parseInt(e[n].substr(7,2),16),c=e[n].substr(9,2*o),l=parseInt(e[n].substr(9+2*o,2),16);switch(i){case 0:d==r&&0!=r||t.data.push({address:a+d,bytes:0,data:[]}),r=d+o;for(var p=o+parseInt(e[n].substr(3,2),16)+parseInt(e[n].substr(5,2),16)+i,b=0;b<2*o;b+=2){var u=parseInt(c.substr(b,2),16),_=t.data.length-1;t.data[_].data.push(u),t.data[_].bytes++,p+=u,t.bytes_total++}p=~p+1&255,p!=l&&(s=!1);break;case 1:t.end_of_file=!0;break;case 2:0!=parseInt(c,16)&&console.log("extended segment address record found - NOT IMPLEMENTED !!!");break;case 3:0!=parseInt(c,16)&&console.log("start segment address record found - NOT IMPLEMENTED !!!");break;case 4:a=parseInt(c.substr(0,2),16)<<24|parseInt(c.substr(2,2),16)<<16;break;case 5:t.start_linear_address=parseInt(c,16)}}t.end_of_file&&s?postMessage(t):postMessage(!1)}function microtime(){var e=(new Date).getTime()/1e3;return e}onmessage=function(e){var s=microtime();read_hex_file(e.data),console.log("HEX_PARSER - File parsed in: "+(microtime()-s).toFixed(4)+" seconds"),close()};